<?php 

namespace Home\Controller;
use Think\Controller;
class SelectController extends Controller{

	public function select(){

		$username=cookie('username');
		if($username){
			if(IS_POST){

				$data=I();
				if(empty($data['user'])){
					$this->ajaxReturn(['code'=>10001,'msg'=>'请填写用户']);
				}
				$model=M('user_phone');
				$date_to=$data['end_time'];
				$date_from=$data['start_time'];
				if ($date_from && $date_to) {

					$where['add_time'] = array(array('egt', $date_from), array('elt', $date_to));

					} else if ($date_from) {

					$where['add_time'] = array('egt',$date_from);

					} else if ($date_to) {

					$where['add_time'] = array('elt', $date_to);

					}

			
				$where['phone']=$data['user'];
				$where['status']=$data['status'];
				$data=$model->where($where)->select();
				// print_r($data);die;
				if($data){
					foreach ($data as &$v) {
						if($v['status']==0){
							$v['status']='失败';
						}else{
							$v['status']='成功';
						}
						
					}
					$this->assign('data',$data);
					$this->ajaxReturn(['code'=>10000,'msg'=>'查询成功','data'=>$data]);
				}else{

					$this->ajaxReturn(['code'=>10001,'msg'=>'查询失败']);
				}

			}else{
				$this->display();
			}
			

		}else{
			redirect(U('Login/login'));
		}
	}


}












 ?>